/*
 *      net_list.h
 *
 *      Copyright 2009 AzureSky <AzureSky.fedora@gmail.com>
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

#ifndef NET_LIST_H_
#define NET_LIST_H_
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <list>

const std::string STATUS[] ={
			"ERROR_STATUS",
			"ESTABLISHED",
			"SYN_SENT",
			"SYN_RECV",
			"FIN_WAIT1",
			"FIN_WAIT2",
			"TIME_WAIT",
			"CLOSE",
			"CLOSE_WAIT",
			"LAST_ACK",
			"LISTEN",
			"CLOSING"
};

struct net_link{
			std::string type;
			std::string local_ip;
			unsigned int local_port;
			std::string remote_ip;
			unsigned int remote_port;
			std::string status;
};

class net_list : public std::list<struct net_link>
{
	public:
		net_list();
		~net_list();
		void read();
		void refresh();
	private:
		std::string to_ip4(char*);
		void add_link(std::string,std::string);
		void read_file(std::string,std::string);
};

#endif /* NET_LIST_H_ */
